<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Dissasemble: src/process/instructionRefParser/insParser.c Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="Hopper_v3.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Dissasemble
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">This project receives as input a file.o and displays the assembly code for that object.</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('ins_parser_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/process/instructionRefParser/insParser.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="ins_parser_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> ============================================================================</span>
<a name="l00003"></a>00003 <span class="comment"> Name        : insParser.c</span>
<a name="l00004"></a>00004 <span class="comment"> Author      :</span>
<a name="l00005"></a>00005 <span class="comment"> Version     :</span>
<a name="l00006"></a>00006 <span class="comment"> Copyright   : Your copyright notice</span>
<a name="l00007"></a>00007 <span class="comment"> Description : Parser a Xml file which contains the instruction attributes</span>
<a name="l00008"></a>00008 <span class="comment"> ============================================================================</span>
<a name="l00009"></a>00009 <span class="comment"> */</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="ins_parser_8h.html">insParser.h</a>&quot;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;<a class="code" href="debug_8h.html">debug.h</a>&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;ctype.h&gt;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 
<a name="l00022"></a><a class="code" href="ins_parser_8c.html#a87dc58a670862f74e86f0ddcdf1c926e">00022</a> <span class="keywordtype">char</span>* <a class="code" href="ins_parser_8c.html#a87dc58a670862f74e86f0ddcdf1c926e" title="Find in a_attrb the property name and returns its content.">findProperty</a>(xmlAttr* a_attrb, <span class="keywordtype">char</span>*name) {
<a name="l00023"></a>00023 
<a name="l00024"></a>00024         xmlAttr *cur_attrb = NULL;
<a name="l00025"></a>00025 
<a name="l00026"></a>00026         <span class="keywordflow">for</span> (cur_attrb = a_attrb; cur_attrb; cur_attrb = cur_attrb-&gt;next)
<a name="l00027"></a>00027         {
<a name="l00028"></a>00028                 <span class="keywordflow">if</span> (strcmp((<span class="keywordtype">char</span>*) cur_attrb-&gt;name, name) == 0)
<a name="l00029"></a>00029                 {
<a name="l00030"></a>00030                         <span class="keywordflow">return</span> (<span class="keywordtype">char</span>*) cur_attrb-&gt;children-&gt;content;
<a name="l00031"></a>00031                 }
<a name="l00032"></a>00032         }
<a name="l00033"></a>00033         <span class="keywordflow">return</span> (<span class="keywordtype">char</span>*) 0;
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 
<a name="l00041"></a><a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7">00041</a> <span class="keywordtype">char</span> <a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(xmlNode * a_node, <span class="keywordtype">char</span>* tagName, xmlNode **myRet) {
<a name="l00042"></a>00042 
<a name="l00043"></a>00043         xmlNode *cur_node = NULL;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         <span class="keywordflow">for</span> (cur_node = a_node; cur_node; cur_node = cur_node-&gt;next) {
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 
<a name="l00048"></a>00048                 <span class="keywordflow">if</span> (strcmp((<span class="keywordtype">char</span>*) cur_node-&gt;name, tagName) == 0)
<a name="l00049"></a>00049                 {
<a name="l00050"></a>00050                         <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#aad1c4e453ff8b99c5cd2a75b213b00c8" title="Debug instruction tag.">DEBUG_INS_TAG</a>, <span class="stringliteral">&quot;TAG: %s\n&quot;</span>, cur_node-&gt;name);
<a name="l00051"></a>00051                         *myRet = cur_node;
<a name="l00052"></a>00052                         <span class="keywordflow">return</span> 1;
<a name="l00053"></a>00053                 }
<a name="l00054"></a>00054                 <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(cur_node-&gt;children, tagName, myRet)) {
<a name="l00055"></a>00055                         <span class="keywordflow">return</span> 1;
<a name="l00056"></a>00056                 }
<a name="l00057"></a>00057         }
<a name="l00058"></a>00058         <span class="keywordflow">return</span> 0;
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">00062</a> <span class="keywordtype">char</span> <a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(xmlNode * a_node,
<a name="l00063"></a>00063                                         <span class="keywordtype">char</span>* tagName,
<a name="l00064"></a>00064                                         <span class="keywordtype">char</span>* propertyName,
<a name="l00065"></a>00065                                         <span class="keywordtype">char</span>* propertyValue,
<a name="l00066"></a>00066                                         xmlNode **myRet)
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068         xmlNode *cur_node = NULL;
<a name="l00069"></a>00069 
<a name="l00070"></a>00070         <span class="keywordtype">char</span> * myChar;
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         <span class="keywordflow">for</span> (cur_node = a_node; cur_node; cur_node = cur_node-&gt;next)
<a name="l00073"></a>00073         {
<a name="l00074"></a>00074 
<a name="l00075"></a>00075                 <span class="keywordflow">if</span> (strcmp((<span class="keywordtype">char</span>*) cur_node-&gt;name, tagName) == 0)
<a name="l00076"></a>00076                 {
<a name="l00077"></a>00077                         <span class="keywordflow">if</span> (strcmp(     myChar = <a class="code" href="ins_parser_8c.html#a87dc58a670862f74e86f0ddcdf1c926e" title="Find in a_attrb the property name and returns its content.">findProperty</a>(  cur_node-&gt;properties,
<a name="l00078"></a>00078                                                                                                 propertyName),
<a name="l00079"></a>00079                                                 propertyValue) == 0)
<a name="l00080"></a>00080                         {
<a name="l00081"></a>00081                                 <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a9c1c407ee7220e1daa2a97e62421bb54" title="Debug instruction properties.">DEBUG_INS_PROPERTIES</a>,
<a name="l00082"></a>00082                                                         <span class="stringliteral">&quot;Property: %s = %s\n&quot;</span>,
<a name="l00083"></a>00083                                                         propertyName, myChar);
<a name="l00084"></a>00084                                 *myRet = cur_node;
<a name="l00085"></a>00085                                 <span class="keywordflow">return</span> 1;
<a name="l00086"></a>00086                         }
<a name="l00087"></a>00087                 }
<a name="l00088"></a>00088                 <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(     cur_node-&gt;children,
<a name="l00089"></a>00089                                                         tagName,
<a name="l00090"></a>00090                                                         propertyName,
<a name="l00091"></a>00091                                                         propertyValue,
<a name="l00092"></a>00092                                                         myRet))
<a name="l00093"></a>00093                 {
<a name="l00094"></a>00094                         <span class="keywordflow">return</span> 1;
<a name="l00095"></a>00095                 }
<a name="l00096"></a>00096         }
<a name="l00097"></a>00097         <span class="keywordflow">return</span> 0;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100 
<a name="l00101"></a><a class="code" href="ins_parser_8c.html#a646d5146e8d5bc747c229cee747b358b">00101</a> <span class="keywordtype">char</span> <a class="code" href="ins_parser_8c.html#a646d5146e8d5bc747c229cee747b358b">findOneByteOpcode</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> op) {
<a name="l00102"></a>00102         xmlDoc *doc = NULL;
<a name="l00103"></a>00103         xmlNode *root_element = NULL;
<a name="l00104"></a>00104         xmlNode *myElement = NULL;
<a name="l00105"></a>00105 
<a name="l00106"></a>00106         <span class="keywordtype">char</span> stringOpcode[5];
<a name="l00107"></a>00107         sprintf(stringOpcode, <span class="stringliteral">&quot;%02x&quot;</span>, op);
<a name="l00108"></a>00108         <a class="code" href="my_lib_8c.html#a938781cf8c88e6ce53a551b42024a99f" title="Converts an input string to uppercase.">convertToUpperCase</a>(stringOpcode);
<a name="l00109"></a>00109         <span class="comment">/*parse the file and get the DOM */</span>
<a name="l00110"></a>00110         doc = xmlReadFile(<a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>, NULL, 0);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112         <span class="keywordflow">if</span> (doc == NULL) {
<a name="l00113"></a>00113                 printf(<span class="stringliteral">&quot;error: could not parse file %s\n&quot;</span>, <a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>);
<a name="l00114"></a>00114                 assert(0);
<a name="l00115"></a>00115         }
<a name="l00116"></a>00116 
<a name="l00117"></a>00117         <span class="comment">/*Get the root element node */</span>
<a name="l00118"></a>00118         root_element = xmlDocGetRootElement(doc);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a>00121         <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(     root_element,
<a name="l00122"></a>00122                                                 <span class="stringliteral">&quot;pri_opcd&quot;</span>,
<a name="l00123"></a>00123                                                 <span class="stringliteral">&quot;value&quot;</span>,
<a name="l00124"></a>00124                                                 stringOpcode,
<a name="l00125"></a>00125                                                 &amp;myElement))
<a name="l00126"></a>00126         {
<a name="l00127"></a>00127                 xmlNode *myElement3 = NULL;
<a name="l00128"></a>00128                 <a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(myElement-&gt;children, <span class="stringliteral">&quot;grp1&quot;</span>, &amp;myElement3);
<a name="l00129"></a>00129                 <span class="keywordflow">if</span> (strcmp((<span class="keywordtype">char</span>*) myElement3-&gt;children-&gt;content, <span class="stringliteral">&quot;prefix&quot;</span>) == 0)
<a name="l00130"></a>00130                 {
<a name="l00131"></a>00131                         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00132"></a>00132                 }
<a name="l00133"></a>00133 
<a name="l00134"></a>00134                 <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae56fdb340b23940f7a64ed2e37c1774a" title="Response code when a process has performed an error in its execution.">STATUS_SUCCESS</a>;
<a name="l00135"></a>00135         }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137         xmlFreeDoc(doc);
<a name="l00138"></a>00138         xmlCleanupParser();
<a name="l00139"></a>00139 
<a name="l00140"></a>00140         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143 
<a name="l00144"></a><a class="code" href="ins_parser_8c.html#a6748a106490f6883dc5bea66a9a5db9f">00144</a> <span class="keywordtype">char</span> <a class="code" href="ins_parser_8c.html#a6748a106490f6883dc5bea66a9a5db9f">findTwoByteOpcode</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> op)
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146         xmlDoc *doc = NULL;
<a name="l00147"></a>00147         xmlNode *root_element = NULL;
<a name="l00148"></a>00148         xmlNode *myElement = NULL;
<a name="l00149"></a>00149 
<a name="l00150"></a>00150         <span class="keywordtype">char</span> stringOpcode[5];
<a name="l00151"></a>00151         sprintf(stringOpcode, <span class="stringliteral">&quot;%02x&quot;</span>, op);
<a name="l00152"></a>00152         <a class="code" href="my_lib_8c.html#a938781cf8c88e6ce53a551b42024a99f" title="Converts an input string to uppercase.">convertToUpperCase</a>(stringOpcode);
<a name="l00153"></a>00153         <span class="comment">/*parse the file and get the DOM */</span>
<a name="l00154"></a>00154         doc = xmlReadFile(<a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>, NULL, XML_PARSE_NOBLANKS);
<a name="l00155"></a>00155 
<a name="l00156"></a>00156         <span class="keywordflow">if</span> (doc == NULL) {
<a name="l00157"></a>00157                 printf(<span class="stringliteral">&quot;error: could not parse file %s\n&quot;</span>, <a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>);
<a name="l00158"></a>00158                 assert(0);
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         <span class="comment">/*Get the root element node */</span>
<a name="l00162"></a>00162         root_element = xmlDocGetRootElement(doc);
<a name="l00163"></a>00163 
<a name="l00164"></a>00164 
<a name="l00165"></a>00165         <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(     root_element-&gt;children-&gt;next,
<a name="l00166"></a>00166                                                 <span class="stringliteral">&quot;pri_opcd&quot;</span>,
<a name="l00167"></a>00167                                                 <span class="stringliteral">&quot;value&quot;</span>,
<a name="l00168"></a>00168                                                 stringOpcode,
<a name="l00169"></a>00169                                                 &amp;myElement))
<a name="l00170"></a>00170         {
<a name="l00171"></a>00171                 xmlNode *myElement3 = NULL;
<a name="l00172"></a>00172 
<a name="l00173"></a>00173                 <a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(myElement-&gt;children, <span class="stringliteral">&quot;grp1&quot;</span>, &amp;myElement3);
<a name="l00174"></a>00174                 <span class="keywordflow">if</span> (strcmp((<span class="keywordtype">char</span>*) myElement3-&gt;children-&gt;content, <span class="stringliteral">&quot;prefix&quot;</span>) == 0)
<a name="l00175"></a>00175                 {
<a name="l00176"></a>00176                         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00177"></a>00177                 }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179                 <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae56fdb340b23940f7a64ed2e37c1774a" title="Response code when a process has performed an error in its execution.">STATUS_SUCCESS</a>;
<a name="l00180"></a>00180         }
<a name="l00181"></a>00181 
<a name="l00182"></a>00182         xmlFreeDoc(doc);
<a name="l00183"></a>00183         xmlCleanupParser();
<a name="l00184"></a>00184 
<a name="l00185"></a>00185         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 <span class="comment">//todo remove dependencies OPCODE_PROPERTIES</span>
<a name="l00189"></a><a class="code" href="ins_parser_8c.html#a2f37aa58429f6120d0071cd8148db6c1">00189</a> <span class="keywordtype">char</span> <a class="code" href="ins_parser_8c.html#a2f37aa58429f6120d0071cd8148db6c1">getOpcodeAtributes</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> op, <a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html" title="Properties of an operation code..">OPCODE_PROPERTIES</a>* opProp) {
<a name="l00190"></a>00190         xmlDoc *doc = NULL;
<a name="l00191"></a>00191         xmlNode *root_element = NULL;
<a name="l00192"></a>00192         xmlNode *myElement = NULL;
<a name="l00193"></a>00193         xmlNode *syntax = NULL;
<a name="l00194"></a>00194         xmlNode *operand = NULL;
<a name="l00195"></a>00195         xmlNode *operandTags = NULL;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         <a class="code" href="common_8h.html#ad8ce12d83f204245685f98caf9d03944" title="One byte.">UINT8</a> operandNumber = 0;
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         <span class="comment">//xmlNode *myElement2 = NULL;</span>
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="keywordtype">char</span> stringOpcode[5];
<a name="l00202"></a>00202         sprintf(stringOpcode, <span class="stringliteral">&quot;%02x&quot;</span>, op);
<a name="l00203"></a>00203         <a class="code" href="my_lib_8c.html#a938781cf8c88e6ce53a551b42024a99f" title="Converts an input string to uppercase.">convertToUpperCase</a>(stringOpcode);
<a name="l00204"></a>00204 
<a name="l00205"></a>00205         <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a15007e4e2267545106fa29e4bc9af4aa" title="Debug operation codes attributes.">DEBUG_INS_OPCODE_ATTRIBUTES</a>,
<a name="l00206"></a>00206                                 <span class="stringliteral">&quot;Getting attributes for opcode: %s\n&quot;</span>,
<a name="l00207"></a>00207                                 stringOpcode);
<a name="l00208"></a>00208 
<a name="l00209"></a>00209         <span class="comment">/*parse the file and get the DOM */</span>
<a name="l00210"></a>00210         doc = xmlReadFile(<a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>, NULL, XML_PARSE_NOBLANKS);
<a name="l00211"></a>00211 
<a name="l00212"></a>00212         <span class="keywordflow">if</span> (doc == NULL) {
<a name="l00213"></a>00213                 printf(<span class="stringliteral">&quot;error: could not parse file %s\n&quot;</span>, <a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>);
<a name="l00214"></a>00214                 assert(0);
<a name="l00215"></a>00215         }
<a name="l00216"></a>00216         <span class="comment">/*Get the root element node */</span>
<a name="l00217"></a>00217         root_element = xmlDocGetRootElement(doc);
<a name="l00218"></a>00218 
<a name="l00219"></a>00219         <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(     root_element,
<a name="l00220"></a>00220                                                 <span class="stringliteral">&quot;pri_opcd&quot;</span>,
<a name="l00221"></a>00221                                                 <span class="stringliteral">&quot;value&quot;</span>,
<a name="l00222"></a>00222                                                 stringOpcode,
<a name="l00223"></a>00223                                                 &amp;myElement))
<a name="l00224"></a>00224         {
<a name="l00225"></a>00225 
<a name="l00226"></a>00226                 <span class="comment">//</span>
<a name="l00227"></a>00227                 <span class="comment">//find syntax tag</span>
<a name="l00228"></a>00228                 <span class="comment">//</span>
<a name="l00229"></a>00229                 <a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(myElement-&gt;children, <span class="stringliteral">&quot;syntax&quot;</span>, &amp;syntax);
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 
<a name="l00232"></a>00232                 <span class="keywordflow">if</span> (syntax-&gt;children)           <span class="comment">//mnemonic</span>
<a name="l00233"></a>00233 
<a name="l00234"></a>00234                 {
<a name="l00235"></a>00235 
<a name="l00236"></a>00236                         strcpy( opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a9e072a07f80500964b1d604b5ee75862" title="mnemonic">mnemonic</a>,
<a name="l00237"></a>00237                                         (<a class="code" href="common_8h.html#a7e125472d65b57f10905accbed140b99" title="Stores 8 bits.">INT8</a>*) syntax-&gt;children-&gt;children-&gt;content);
<a name="l00238"></a>00238                 }
<a name="l00239"></a>00239                 operand = syntax-&gt;children-&gt;next;
<a name="l00240"></a>00240 
<a name="l00241"></a>00241                 <span class="keywordflow">while</span> (operand)
<a name="l00242"></a>00242                 {
<a name="l00243"></a>00243 
<a name="l00244"></a>00244 
<a name="l00245"></a>00245                         <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(operand-&gt;children, <span class="stringliteral">&quot;a&quot;</span>, &amp;operandTags))
<a name="l00246"></a>00246                         {
<a name="l00247"></a>00247                                 <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a9c1c407ee7220e1daa2a97e62421bb54" title="Debug instruction properties.">DEBUG_INS_PROPERTIES</a>,
<a name="l00248"></a>00248                                                         <span class="stringliteral">&quot;a: %s\n&quot;</span>,
<a name="l00249"></a>00249                                                         operandTags-&gt;children-&gt;content);
<a name="l00250"></a>00250                                 strcpy( opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a675718a27aa9afcb2091cb80e6605667" title="Addressing Method.">a</a>,
<a name="l00251"></a>00251 
<a name="l00252"></a>00252                                                 (<a class="code" href="common_8h.html#a7e125472d65b57f10905accbed140b99" title="Stores 8 bits.">INT8</a>*) operandTags-&gt;children-&gt;content);
<a name="l00253"></a>00253                         }
<a name="l00254"></a>00254 
<a name="l00255"></a>00255                         <span class="keywordflow">if</span> (<a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(operand-&gt;children, <span class="stringliteral">&quot;t&quot;</span>, &amp;operandTags))
<a name="l00256"></a>00256                         {
<a name="l00257"></a>00257                                 <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a9c1c407ee7220e1daa2a97e62421bb54" title="Debug instruction properties.">DEBUG_INS_PROPERTIES</a>,
<a name="l00258"></a>00258                                                         <span class="stringliteral">&quot;t: %s\n&quot;</span>,
<a name="l00259"></a>00259                                                         operandTags-&gt;children-&gt;content);
<a name="l00260"></a>00260                                 strcpy( opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a862599f1889ae51550769f8605615625" title="Operand Type.">t</a>,
<a name="l00261"></a>00261 
<a name="l00262"></a>00262                                                 (<a class="code" href="common_8h.html#a7e125472d65b57f10905accbed140b99" title="Stores 8 bits.">INT8</a>*) operandTags-&gt;children-&gt;content);
<a name="l00263"></a>00263                         }
<a name="l00264"></a>00264 
<a name="l00265"></a>00265 
<a name="l00266"></a>00266                         <span class="keywordflow">if</span> (*opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a675718a27aa9afcb2091cb80e6605667" title="Addressing Method.">a</a> != 0
<a name="l00267"></a>00267                                         || *opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a862599f1889ae51550769f8605615625" title="Operand Type.">t</a> != 0)
<a name="l00268"></a>00268                         {
<a name="l00269"></a>00269 
<a name="l00270"></a>00270                                 operandNumber++;
<a name="l00271"></a>00271                         }<span class="comment">//todo check patch</span>
<a name="l00272"></a>00272                         <span class="keywordflow">else</span>
<a name="l00273"></a>00273                         {
<a name="l00274"></a>00274                                 opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a675718a27aa9afcb2091cb80e6605667" title="Addressing Method.">a</a>[0] = <span class="charliteral">&#39;H&#39;</span>;
<a name="l00275"></a>00275                                 opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a675718a27aa9afcb2091cb80e6605667" title="Addressing Method.">a</a>[1] = <span class="charliteral">&#39;1&#39;</span>;
<a name="l00276"></a>00276                                 *opProp-&gt;<a class="code" href="struct_o_p_c_o_d_e___p_r_o_p_e_r_t_i_e_s.html#a15d4fa32d95f297a491a56c9398b419d" title="Addressing method.">operand_at</a>[operandNumber].<a class="code" href="struct__addresing_and_type.html#a862599f1889ae51550769f8605615625" title="Operand Type.">t</a> = <span class="charliteral">&#39;b&#39;</span>;
<a name="l00277"></a>00277                                 <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a9c1c407ee7220e1daa2a97e62421bb54" title="Debug instruction properties.">DEBUG_INS_PROPERTIES</a>,<span class="stringliteral">&quot;a: %s\n&quot;</span>,<span class="stringliteral">&quot;H1&quot;</span>);
<a name="l00278"></a>00278                                 <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a9c1c407ee7220e1daa2a97e62421bb54" title="Debug instruction properties.">DEBUG_INS_PROPERTIES</a>,<span class="stringliteral">&quot;t: %c\n&quot;</span>,<span class="charliteral">&#39;b&#39;</span>);
<a name="l00279"></a>00279 
<a name="l00280"></a>00280                                 operandNumber++;
<a name="l00281"></a>00281                         }
<a name="l00282"></a>00282 
<a name="l00283"></a>00283                         operand = operand-&gt;next;
<a name="l00284"></a>00284 
<a name="l00285"></a>00285                 }
<a name="l00286"></a>00286 
<a name="l00287"></a>00287                 <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae56fdb340b23940f7a64ed2e37c1774a" title="Response code when a process has performed an error in its execution.">STATUS_SUCCESS</a>;
<a name="l00288"></a>00288         }
<a name="l00289"></a>00289 
<a name="l00290"></a>00290         xmlFreeDoc(doc);
<a name="l00291"></a>00291         xmlCleanupParser();
<a name="l00292"></a>00292 
<a name="l00293"></a>00293         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 
<a name="l00296"></a><a class="code" href="ins_parser_8h.html#a19bc9ef85981f3ff6b58a392cd80d77f">00296</a> <span class="keywordtype">void</span> <a class="code" href="ins_parser_8c.html#a19bc9ef85981f3ff6b58a392cd80d77f">hh</a>() {
<a name="l00297"></a>00297         xmlDoc *doc = NULL;
<a name="l00298"></a>00298         xmlNode *root_element = NULL;
<a name="l00299"></a>00299         xmlNode *myElement = NULL;
<a name="l00300"></a>00300         xmlNode *myElement2 = NULL;
<a name="l00301"></a>00301 
<a name="l00302"></a>00302         <span class="comment">/*</span>
<a name="l00303"></a>00303 <span class="comment">         * this initialize the library and check potential ABI mismatches</span>
<a name="l00304"></a>00304 <span class="comment">         * between the version it was compiled for and the actual shared</span>
<a name="l00305"></a>00305 <span class="comment">         * library used.</span>
<a name="l00306"></a>00306 <span class="comment">         */</span>
<a name="l00307"></a>00307 
<a name="l00308"></a>00308         <span class="comment">/*parse the file and get the DOM */</span>
<a name="l00309"></a>00309         doc = xmlReadFile(<a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>, NULL, 0);
<a name="l00310"></a>00310 
<a name="l00311"></a>00311         <span class="keywordflow">if</span> (doc == NULL) {
<a name="l00312"></a>00312                 printf(<span class="stringliteral">&quot;error: could not parse file %s\n&quot;</span>, <a class="code" href="config_8h.html#ab58d38b69271d678ea565e981328a246" title="Xml file that contains the attributes and definitions of the various operations of existing Intel X86...">INSTRUCTION_REF_FILE</a>);
<a name="l00313"></a>00313         }
<a name="l00314"></a>00314 
<a name="l00315"></a>00315         <a class="code" href="ins_parser_8c.html#ab7109c9de18d0c68eadefb08ba162bb3">getTagProperty</a>(root_element, <span class="stringliteral">&quot;pri_opcd&quot;</span>, <span class="stringliteral">&quot;value&quot;</span>, <span class="stringliteral">&quot;03&quot;</span>, &amp;myElement);
<a name="l00316"></a>00316         <a class="code" href="ins_parser_8c.html#ac5c5d22cc4bf6fb9d3be300a1b4740b7" title="Find in a_attrb the property name and returns its content.">getTag</a>(myElement, <span class="stringliteral">&quot;mnem&quot;</span>, &amp;myElement2);
<a name="l00317"></a>00317 
<a name="l00318"></a>00318         <a class="code" href="ins_parser_8c.html#a6748a106490f6883dc5bea66a9a5db9f">findTwoByteOpcode</a>(0x00);
<a name="l00319"></a>00319         <span class="comment">//getOpcodeAtributes((unsigned char)0x89,buf);</span>
<a name="l00320"></a>00320         <span class="comment">//findOpcode((unsigned char)0x66,buf);</span>
<a name="l00321"></a>00321 
<a name="l00322"></a>00322         printf(<span class="stringliteral">&quot;OPCODE: %s\n&quot;</span>, myElement2-&gt;children-&gt;content);
<a name="l00323"></a>00323         <span class="comment">//myElement = findOpcode(root_element, 0x3);</span>
<a name="l00324"></a>00324         <span class="comment">//print_element_names(myElement);</span>
<a name="l00325"></a>00325         <span class="comment">/*free the document */</span>
<a name="l00326"></a>00326         xmlFreeDoc(doc);
<a name="l00327"></a>00327 
<a name="l00328"></a>00328         <span class="comment">/*</span>
<a name="l00329"></a>00329 <span class="comment">         *Free the global variables that may</span>
<a name="l00330"></a>00330 <span class="comment">         *have been allocated by the parser.</span>
<a name="l00331"></a>00331 <span class="comment">         */</span>
<a name="l00332"></a>00332         xmlCleanupParser();
<a name="l00333"></a>00333 }
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="ins_parser_8c.html">insParser.c</a>      </li>

    <li class="footer">Generated on Thu Oct 11 2012 12:28:10 for Dissasemble by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
